/*
 * sp002.cpp
 *
 *  Created on: 2012-11-14
 *      Author: feng
 */



#include "sample.h"

void CSp002::InitOpenGL() {
	glClearColor(0.0f,0.0f,0.0f,1.0f);
	glColor3f(0.0f,1.0f,0.0f);
	glShadeModel(GL_FLAT);
	glFrontFace(GL_CW);
}

void CSp002::RenderOnce() {
//	glEnable(GL_CULL_FACE);
	glEnable(GL_DEPTH_TEST);
	glPolygonMode(GL_BACK,GL_LINE);
//	glPolygonMode(GL_BACK,GL_FILL);

	GLfloat radius,angle,x,y;
	radius = 50.0f;
	int iPivot = 1;


	glBegin(GL_TRIANGLE_FAN);
	glVertex3f(0.0f,0.0f,75.0f);
	for (angle = 0.0f; angle < 2*GL_PI; angle += (GL_PI/8.0f)) {
		x = radius * sin(angle);
		y = radius * cos(angle);
		if (iPivot%2 == 0)
			glColor3f(1.0f,0.0f,0.0f);
		else
			glColor3f(0.0f,0.0f,1.0f);
		glVertex3f(x,y,0.0f);
		iPivot += 1;
	}
	glEnd();

	glBegin(GL_TRIANGLE_FAN);
	glVertex2f(0.0f,0.0f);
	for (angle = 0.0f; angle < 2*GL_PI; angle += (GL_PI/8.0f)) {
		x = radius * sin(angle);
		y = radius * cos(angle);
		if (iPivot%2 == 0)
			glColor3f(1.0f,0.0f,0.0f);
		else
			glColor3f(0.0f,0.0f,1.0f);
		glVertex2f(x,y);
		iPivot += 1;
	}
	glEnd();

}
